﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WLWZGao6.APItitlion.IService;
using WLWZGao6.Domain.Common;
using WLWZGao6.Domain.Model;
using WLWZGao6.Domain.Dto;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;//给这个控制器加锁别人无法访问加入[AllowAnonymous]能够访问
namespace WLWZGao6.APIHost.Controllers
{
    /// <summary>
    /// 角色控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        /// <summary>
        /// 角色服务接口
        /// </summary>
        public IRoleService _roleService;
        /// <summary>
        /// 接口实现
        /// </summary>
        /// <param name="roleService"></param>
        public RoleController(IRoleService roleService)
        {
            _roleService = roleService;
        }
        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        [HttpPost]
        
        public EData RoleAdd(Role role)
        {
            return _roleService.RoleAdd(role);
        }
        /// <summary>
        /// 角色删除
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        [HttpPost]
        public EData RoleDel(int Ids)
        {
            return _roleService.RoleDel(Ids);
        }
        /// <summary>
        /// 角色显示
        /// </summary>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        [HttpGet]
        public EData RoleShow(string RoleName, int Index, int Size)
        {
            return _roleService.RoleShow(RoleName,Index,Size);
        }
        /// <summary>
        /// 角色修改
        /// </summary>
        /// <param name="Ids"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        [HttpPost]
        public EData RoleUpd(int Ids, Role role)
        {
            return _roleService.RoleUpd(Ids, role);
        }
    }
}
